package com.lmiot.xyclick.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.lmiot.xyclick.Util.SpFlag;
import com.lmiot.xyclick.AD.SDK.ADSDK;
import com.lmiot.xyclick.App.MyApp;
import com.lkx.liandianqinew.R;
import com.lmiot.xyclick.Util.CheckUtil;
import com.lmiot.xyclick.Util.LayoutDialogUtil;
import com.xiaoyi.intentsdklibrary.SDK.Action.ActionAsSDK;
import com.xiaoyi.intentsdklibrary.SDK.Action.ActionNormalSDK;
import com.xiaoyi.intentsdklibrary.SDK.Action.AsconnectBean;
import com.youyi.yypermissionlibrary.SDK.YYPerUtils;
import com.youyi.yyviewsdklibrary.Dialog.util.ToastUtil;
import com.youyi.yyviewsdklibrary.View.TitleBarView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class PermissionActivity extends AppCompatActivity implements View.OnClickListener {
    TextView mIdAs;
    TextView mIdAsBt;
    ImageView mIdAsNo;
    ImageView mIdAsYes;
    TextView mIdFloat;
    TextView mIdFloatBt;
    ImageView mIdFloatNo;
    ImageView mIdFloatYes;
    TextView mIdNotic;
    TextView mIdNoticBt;
    ImageView mIdNoticNo;
    ImageView mIdNoticYes;
    TextView mIdOtherBt;
    TitleBarView mIdTitleBar;
    TextView mIdXiaomi;
    TextView mIdXiaomiBt;
    LinearLayout mIdXiaomiLayout;
    View mIdXiaomiLayoutLine;
    ImageView mIdXiaomiNo;
    ImageView mIdXiaomiYes;
    private Intent mIntent;

    /* access modifiers changed from: protected */
    @Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.SupportActivity, android.support.v4.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_permission);
        initView();
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        this.mIdTitleBar.setOnItemClickListener(new TitleBarView.onItemClickListener() {
            /* class com.lmiot.xyclick.Activity.PermissionActivity.AnonymousClass1 */

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onTitleClick(View view) {
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onBackClick(View view) {
                PermissionActivity.this.finish();
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onMenuClick(View view) {
                PermissionActivity.this.mIntent = new Intent(PermissionActivity.this, WebViewActivity.class);
                PermissionActivity.this.mIntent.putExtra(SpFlag.k, "《隐私政策》");
                if (ADSDK.nowVersion.startsWith("HW")) {
                    PermissionActivity.this.mIntent.putExtra("url", "https://ai.xiaoyizhineng.com:441/download/HelpVideo/autoclick/privateh.html");
                } else {
                    PermissionActivity.this.mIntent.putExtra("url", "https://ai.xiaoyizhineng.com:441/download/HelpVideo/autoclick/private.html");
                }
                PermissionActivity permissionActivity = PermissionActivity.this;
                permissionActivity.startActivity(permissionActivity.mIntent);
            }
        });
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(AsconnectBean asconnectBean) {
        if (asconnectBean.isConnect()) {
            checkMethod();
        } else {
            checkMethod();
        }
    }

    /* access modifiers changed from: protected */
    @Override // android.support.v4.app.FragmentActivity
    public void onResume() {
        super.onResume();
        checkMethod();
    }

    private void checkMethod() {
        boolean checkAs = ActionAsSDK.getInstance().checkAs(MyApp.getContext());
        boolean hasOp = YYPerUtils.hasOp();
        boolean hasBgOp = YYPerUtils.hasBgOp();
        boolean checkNotic = CheckUtil.checkNotic(this);
        int i = 0;
        this.mIdAsYes.setVisibility(checkAs ? View.VISIBLE : View.GONE);
        this.mIdAs.setVisibility(checkAs ? View.VISIBLE : View.GONE);
        this.mIdAsNo.setVisibility(checkAs ? View.GONE : View.VISIBLE);
        this.mIdAsBt.setVisibility(checkAs ? View.GONE : View.VISIBLE);
        this.mIdXiaomiYes.setVisibility(hasBgOp ? View.VISIBLE : View.GONE);
        this.mIdXiaomi.setVisibility(hasBgOp ? View.VISIBLE : View.GONE);
        this.mIdXiaomiNo.setVisibility(hasBgOp ? View.GONE : View.VISIBLE);
        this.mIdXiaomiBt.setVisibility(hasBgOp ? View.GONE : View.VISIBLE);
        this.mIdFloatYes.setVisibility(hasOp ? View.VISIBLE : View.GONE);
        this.mIdFloat.setVisibility(hasOp ? View.VISIBLE : View.GONE);
        this.mIdFloatNo.setVisibility(hasOp ? View.GONE : View.VISIBLE);
        this.mIdFloatBt.setVisibility(hasOp ? View.GONE : View.VISIBLE);
        this.mIdNoticYes.setVisibility(checkNotic ? View.VISIBLE : View.GONE);
        this.mIdNotic.setVisibility(checkNotic ? View.VISIBLE : View.GONE);
        this.mIdNoticNo.setVisibility(checkNotic ? View.GONE : View.VISIBLE);
        TextView textView = this.mIdNoticBt;
        if (checkNotic) {
            i = 8;
        }
        textView.setVisibility(i);
    }

    private void initView() {
        this.mIdTitleBar = (TitleBarView) findViewById(R.id.id_title_bar);
        this.mIdAsYes = (ImageView) findViewById(R.id.id_as_yes);
        this.mIdAsNo = (ImageView) findViewById(R.id.id_as_no);
        this.mIdAs = (TextView) findViewById(R.id.id_as);
        this.mIdAsBt = (TextView) findViewById(R.id.id_as_bt);
        this.mIdFloatYes = (ImageView) findViewById(R.id.id_float_yes);
        this.mIdFloatNo = (ImageView) findViewById(R.id.id_float_no);
        this.mIdFloat = (TextView) findViewById(R.id.id_float);
        this.mIdFloatBt = (TextView) findViewById(R.id.id_float_bt);
        this.mIdXiaomiYes = (ImageView) findViewById(R.id.id_xiaomi_yes);
        this.mIdXiaomiNo = (ImageView) findViewById(R.id.id_xiaomi_no);
        this.mIdXiaomi = (TextView) findViewById(R.id.id_xiaomi);
        this.mIdXiaomiBt = (TextView) findViewById(R.id.id_xiaomi_bt);
        this.mIdXiaomiLayout = (LinearLayout) findViewById(R.id.id_xiaomi_layout);
        this.mIdXiaomiLayoutLine = findViewById(R.id.id_xiaomi_layout_line);
        this.mIdNoticYes = (ImageView) findViewById(R.id.id_notic_yes);
        this.mIdNoticNo = (ImageView) findViewById(R.id.id_notic_no);
        this.mIdNotic = (TextView) findViewById(R.id.id_notic);
        this.mIdNoticBt = (TextView) findViewById(R.id.id_notic_bt);
        this.mIdOtherBt = (TextView) findViewById(R.id.id_other_bt);
        this.mIdAsBt.setOnClickListener(this);
        this.mIdFloatBt.setOnClickListener(this);
        this.mIdXiaomiBt.setOnClickListener(this);
        this.mIdNoticBt.setOnClickListener(this);
        this.mIdOtherBt.setOnClickListener(this);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.id_as_bt /*{ENCODED_INT: 2131296467}*/:
                if (YYPerUtils.getPhoneCompany().equals("xiaomi")) {
                    LayoutDialogUtil.showSureDialog(this, "操作步骤", "请按以下步骤开启:\n\n无障碍>更多已下载到服务>连点器>把开关打开\n\n注：\n1.如果一直提示无法开启，请重启一次手机！\n\n2.如果提示被遮挡，请重启一次手机！", true, false, "取消", "前往开启", new LayoutDialogUtil.OnResultClickListener() {
                        /* class com.lmiot.xyclick.Activity.PermissionActivity.AnonymousClass3 */

                        @Override // com.lmiot.xyclick.Util.LayoutDialogUtil.OnResultClickListener
                        public void result(boolean z) {
                            if (z) {
                                ToastUtil.warning("请找到：已下载的服务");
                                ActionNormalSDK.getInstance().gotoAsSetting(PermissionActivity.this);
                            }
                        }
                    });
                    return;
                } else {
                    LayoutDialogUtil.showSureDialog(this, "操作步骤", "请按以下步骤开启:\n\n无障碍>连点器>把开关打开\n\n注：\n1.如果一直提示无法开启，请重启一次手机！\n\n2.如果提示被遮挡，请重启一次手机！", true, false, "取消", "前往开启", new LayoutDialogUtil.OnResultClickListener() {
                        /* class com.lmiot.xyclick.Activity.PermissionActivity.AnonymousClass4 */

                        @Override // com.lmiot.xyclick.Util.LayoutDialogUtil.OnResultClickListener
                        public void result(boolean z) {
                            if (z) {
                                ToastUtil.warning("找到连点器，然后打开");
                                ActionNormalSDK.getInstance().gotoAsSetting(PermissionActivity.this);
                            }
                        }
                    });
                    return;
                }
            case R.id.id_float_bt /*{ENCODED_INT: 2131296644}*/:
                ActionNormalSDK.getInstance().gotoFloatSetting(this);
                return;
            case R.id.id_notic_bt /*{ENCODED_INT: 2131296800}*/:
                ActionNormalSDK.getInstance().gotoNoticSetting(this);
                return;
            case R.id.id_other_bt /*{ENCODED_INT: 2131296818}*/:
                ActionNormalSDK.getInstance().gotoSelfSetting(this);
                return;
            case R.id.id_xiaomi_bt /*{ENCODED_INT: 2131297011}*/:
                LayoutDialogUtil.showSureDialog(this, "操作步骤", "请按以下步骤开启:\n\n应用详情>权限管理>后台弹出界面>点击允许\n\n", true, false, "取消", "前往开启", new LayoutDialogUtil.OnResultClickListener() {
                    /* class com.lmiot.xyclick.Activity.PermissionActivity.AnonymousClass2 */

                    @Override // com.lmiot.xyclick.Util.LayoutDialogUtil.OnResultClickListener
                    public void result(boolean z) {
                        if (z) {
                            ActionNormalSDK instance = ActionNormalSDK.getInstance();
                            PermissionActivity permissionActivity = PermissionActivity.this;
                            instance.gotoPermissionSetting(permissionActivity, permissionActivity.getPackageName());
                        }
                    }
                });
                return;
            default:
                return;
        }
    }

    /* access modifiers changed from: protected */
    @Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity
    public void onDestroy() {
        super.onDestroy();
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }
}
